import urllib.request
from urllib.request import urlretrieve
import re

m = 1
for num in range(1,6):
    url = 'https://image.baidu.com/search/acjson?tn=resultjson_com&ipn=rj&ct=201326592&is=&fp=result&queryWord=%E6%9B%BC%E8%81%94&cl=2&lm=-1&ie=utf-8&oe=utf-8&adpicid=&st=-1&z=&ic=0&word=%E6%9B%BC%E8%81%94&s=&se=&tab=&width=&height=&face=0&istype=2&qc=&nc=1&fr=&pn='+str((num-1)*30)+'&rn=30'
    content = urllib.request.urlopen(url).read().decode("utf-8","ignore")
    pat = '"middleURL":"(.*?)"'
    picList = re.compile(pat,re.S).findall(content)
    for pic in picList:
        urlretrieve(pic,'./baiduPic/MU_'+str(m)+'.jpg')
        m += 1
print("写入成功！！！")